package com.xgp.unsafe;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

/**
 * java.util.ConcurrentModificationException
 *          //1、并发的HashMap
 *         Map<String, String> map = new ConcurrentHashMap<>();
 */
public class MapTest {
    public static void main(String[] args) {
        //map 是这样用的吗？默认等价于什么
        Map<String, String> map = new ConcurrentHashMap<>();
        // 加载因子、初始化容量
        for(int i = 1;i <= 50;i++) {
            new Thread(() -> {
                map.put(Thread.currentThread().getName(),UUID.randomUUID().toString().substring(0,5));
                System.out.println(map);
            },String.valueOf(i)).start();
        }
    }
}
